import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JPanel;


public class Board extends JPanel implements Runnable, KeyListener{
	private Player player;
	private boolean flagLeft = true, flagRight = true;
	public Board() {
		this.addKeyListener(this);
	}
	@Override
	public void run() {
		this.player = new Player();
		while(true){
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
//			this.movePlayer();
			this.repaint();
		}
	}
	
	@Override
	public void paint(Graphics g) {
		super.paint(g);
		g.drawImage(this.player.getImage(), this.player.getX(), this.player.getY(), this);
		g.setColor(Color.blue);
		g.drawLine(50, 350, 450, 350);
	}
	
	public void movePlayer(KeyEvent k){
		if(k.getKeyCode() == KeyEvent.KEY_LOCATION_LEFT && this.player.getX() > 50){
			this.player.setX(this.player.getX()-2);
		}
	}
	@Override
	public void keyPressed(KeyEvent e) {
		
	}
	@Override
	public void keyReleased(KeyEvent e) {
		if(e.getKeyCode() == KeyEvent.KEY_LOCATION_LEFT){
			this.player.setX(this.player.getX()-2);
		}
	}
	@Override
	public void keyTyped(KeyEvent e) {
		
	}
	
	
}
